﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Tank
{
    /// <summary>
    /// 炮弹类
    /// </summary>
    public abstract class Shell : TankMember
    {
        

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="role">发子弹的角色</param>
        /// <param name="life">子弹的生命</param>
        /// <param name="width">子弹的长</param>
        /// <param name="height">子弹的宽</param>
        /// <param name="speed">子弹的速度</param>
        /// <param name="power">子弹的威力</param>
         public Shell(Roles role, int life, int width, int height, int speed, int power)
            : base(role.X+role.Width/2-6,role.Y+role.Height/2-6,life,width,height,speed,role.Dir)
        {
            this.Master = role;
            this.Power = power;
        }

        /// <summary>
        /// 子弹的移动方法
        /// </summary>
        public override void Move() 
        {
            switch (this.Dir)
            {
                case Direction.U:
                    this.Y -= Sp;
                    break;
                case Direction.D:
                    this.Y += Sp;
                    break;
                case Direction.L:
                    this.X -= Sp;
                    break;
                case Direction.R:
                    this.X += Sp;
                    break;
            }
            if (this.X < 0 || this.Y < 0 || this.X > 780 || this.Y > 600)   //当子弹出了边界
            {
                this.Life = 0;     //生命为0;
            }
        }

        #region 弹药的属性

        /// <summary>
        /// 弹药的威力
        /// </summary>
        public int Power { get; set; }

        /// <summary>
        /// 所属者
        /// </summary>
        public Roles Master { get; set; }

        #endregion
    }
}
